package com.sgb.kjwl.view.ui.adapter.enterprise;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.ParentAreaEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class ServiceFirstAdapter extends BaseRecycleAdapter<ParentAreaEntity<List<ParentAreaEntity>>> {
    private int choiceindex = 0;
    public ServiceFirstAdapter(Context context, List<ParentAreaEntity<List<ParentAreaEntity>>> datas) {
        super(context, R.layout.item_service_dt, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final ParentAreaEntity<List<ParentAreaEntity>> entity) {
        holder.setBinding(BR.viewModel, entity);
        TextView textView = holder.getView(R.id.tv_category_item);
        if(holder.getPosition()==choiceindex){
            textView.setSelected(true);
            holder.getView(R.id.root_layout).setSelected(true);

        }else {
            textView.setSelected(false);
            holder.getView(R.id.root_layout).setSelected(false);
        }
    }
    public void setChoiceindex(int choiceindex){
        this.choiceindex = choiceindex;
        notifyDataSetChanged();
    }
}
